from typing import List

from llama_index.core.agent.workflow import  FunctionAgent
from llama_index.core.indices.common.struct_store.sql import SQLStructDatapointExtractor
from llama_index.core.vector_stores import SimpleVectorStore
from llama_index.core.schema import  TextNode
from llama_index.core import Settings, SimpleKeywordTableIndex, SummaryIndex, get_response_synthesizer, \
    DocumentSummaryIndex, TreeIndex, VectorStoreIndex
from llama_index.embeddings.zhipuai import ZhipuAIEmbedding
from llama_index.core.graph_stores import SimplePropertyGraphStore
from llama_index.core.schema import Document
from pydantic import BaseModel

embed_model = ZhipuAIEmbedding(
    model="embedding-2",
    api_key="f387f5e4837d4e4bba6d267682a957c9.PmPiTw8qVlsI2Oi5"
    # With the `embedding-3` class
    # of models, you can specify the size
    # of the embeddings you want returned.
    # dimensions=1024
)
Settings.embed_model=embed_model

from llama_index.llms.deepseek import DeepSeek

llm = DeepSeek(model="deepseek-chat", api_key="sk-605e60a1301040759a821b6b677556fb")
Settings.llm = llm
from llama_index.core.extractors.metadata_extractors import (
    KeywordExtractor,
    PydanticProgramExtractor,
    QuestionsAnsweredExtractor,
    SummaryExtractor,
    TitleExtractor,
)
from llama_index.core.extractors.document_context import DocumentContextExtractor


# indices
from llama_index.core.indices.keyword_table.base import (
    GPTKeywordTableIndex,
    KeywordTableIndex,
)
from llama_index.core.indices.keyword_table.rake_base import (
    GPTRAKEKeywordTableIndex,
    RAKEKeywordTableIndex,
)
from llama_index.core.indices.keyword_table.retrievers import (
    KeywordTableGPTRetriever,
    KeywordTableRAKERetriever,
    KeywordTableSimpleRetriever,
)
from llama_index.core.indices.keyword_table.simple_base import (
    GPTSimpleKeywordTableIndex,
    SimpleKeywordTableIndex,
)

text="""2022年6月14日，江苏南京大报恩塔与“超级月亮”相映成景。新华社发（苏阳 摄）　
今年农历八月的这次满月，也算是一次“超级月亮”。月球的公转轨道是椭圆形的，
地月平均距离约是38万千米，离得最远的时候能达到40万千米，近的时候只有35万多千米。
如果月球位于近地点前后又恰逢满月，就是所谓的”。
这次的中秋节和之后的农历八月十六晚上，月球距离我们大约是36万千米。虽然并非全年最大满月，
但也算是“排进前三”的“超级月亮”了。"""


documents=[Document(text=x) for x in text.split("\n")]

index=VectorStoreIndex.from_documents(documents)
rs=index.as_retriever()
nodes=rs.retrieve("超大月亮")
print(nodes)

